<template>
	<div class="zhengtuojianhuo">
		<van-nav-bar :fixed="true" class="navBar" title="改拣货数" left-arrow @click-left="$router.go(-1)"></van-nav-bar>




		<div class="goodsFromWarp">
				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">拣货容器：</div>
						</div>

						<van-field
							 class="skuInput"
							 clearable
							 v-model="editForm.jhrq"
							 placeholder="请填写拣货容器"
							 @keyup="onEnter($event,do_inputspbar)"
						 />
				</div>

				<div class="goodsInputWarp">
						<div class="goodsInputLabel">
							<div class="goodsInputBorder"></div>
							<div class="skuName">商品条码：</div>
						</div>

						<van-field
							 class="skuInput"
							 clearable
							 v-model="editForm.itemid"
							 placeholder="请填写商品条码"
							 @keyup="onEnter($event,do_inputspbarItem)"
						 />
				</div>
		</div>




				<div class="goodsFromWarp" >

						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">波次单号：</div>
								</div>

								<div class="skuNoInput">
									{{editForm.bill}}
								</div>
						</div>

						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">要货门店：</div>
								</div>

								<div class="skuNoInput">
									{{editForm.xs_ck_storeid}}
								</div>
						</div>

						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">商品名称：</div>
								</div>

								<div class="skuNoInput">
									{{editForm.subsname}}
								</div>
						</div>

						<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">仓位编码：</div>
								</div>

								<div class="skuNoInput">
									{{editForm.cwno}}
								</div>
						</div>


						<div class="goodsInputWarp">
							<div class="goodsInputLabel">
								<div class="goodsInputBorder"></div>
								<div class="skuName">箱装：</div>
							</div>

							<div class="skuNoInput">
								{{editForm.unit}}
							</div>
						</div>



					<div class="goodsInputWarp">
								<div class="goodsInputLabel">
									<div class="goodsInputBorder"></div>
									<div class="skuName">箱数：</div>
								</div>

								<van-field
									 class="skuInput"
									 v-model="editForm.pack"
									 clearable
									 placeholder="请填写箱数"
								 />
						</div>



						<div class="goodsInputWarp">
									<div class="goodsInputLabel">
										<div class="goodsInputBorder"></div>
										<div class="skuName">散数：</div>
									</div>

									<van-field
										 class="skuInput"
										 v-model="editForm.qty"
										 clearable
										 placeholder="请填写散数"
									 />
						</div>


				</div>








		<div class="skuBtn">
			<van-button type="info" :disabled="isdisabled" @click="lingquBtn()">领取任务</van-button>
			<van-button type="info" :disabled="isdisabled" @click="saveGoodsBtn()">确认</van-button>
			<!-- <van-button type="info" :disabled="isdisabled" @click="mubiaoBtn()">目标容器</van-button> -->
		</div>


		<van-overlay :show="isSkuVisible" :lock-scroll="false">
			<div class="shipandanWrapper">
					<van-sticky>
						<van-nav-bar class="navBar" title="商品列表" left-arrow @click-left="isSkuVisible = false"></van-nav-bar>
					</van-sticky>
					<div class="shipandanCon" @click.stop>
							<div  v-for="(row,i) in skuData" :key="i" class="danjuRow" @click="selectSkuClick(row,i)" >
								<van-row class="skuList">
								  <van-col span="24"> <span>商品名称：</span> {{row.subsname}}</van-col>
								</van-row>

								<van-row class="skuList" >
								  <van-col span="24"> <span>波次号：</span> {{row.bill}}</van-col>
								</van-row>

								<van-row class="skuList"  >
									<van-col span="24"> <span>商品编码：</span> {{row.itemid}}</van-col>
								</van-row>

								<van-row class="skuList"  >
									<van-col span="12"> <span>箱装：</span> {{row.unit}}</van-col>
									<van-col span="12"> <span>箱数：</span> {{row.pack}}</van-col>
								</van-row>

								<van-row class="skuList"  >
									<van-col span="12"> <span>散数：</span> {{row.qty}}</van-col>
									<van-col span="12"> <span>分配数：</span> {{row.yjtotqty}}</van-col>
								</van-row>

								<van-row class="skuList"  >
									<van-col span="24"> <span>拣货人：</span> {{row.jhr}}</van-col>
								</van-row>
								<van-row class="skuList"  >
									<van-col span="24"> <span>仓位号：</span> {{row.cwno}}</van-col>
								</van-row>

							</div>
					</div>
			</div>
		</van-overlay>


	</div>
</template>

<script>

export default {
  name: 'gaijianhuoshu',
  data() {
    return {
			editForm:{
				jhrq:'J20250313',
				itmeid:'',
				bill:'',
				ck_storeid: '',
				cwno: '',
				itemid:'',
				jhbq: '',
				jhr: '',
				pack: '',
				qty: '',
				subid: '',
				subsname: '',
				unit:'',
				yjtotqty:'',
			},
			isdisabled:false,
			isLingQuVisible:false,
			skuData:[
				{
					subsname:''
				}
			],
			isSkuVisible:false,
			index:0,
		};
  },
	computed: {
	   ryuser: function(){
	     return this.GWO(true).gUSER;
	   }
	},
  methods: {
		do_inputspbar(pmtxt){
			console.log(pmtxt)  //扫描枪获取的参数
			this.editForm.jhrq = pmtxt
			this.lingquBtn()
		},
		do_inputspbarItem(pmtxt){
			console.log(pmtxt)  //扫描枪获取的参数
			this.editForm.itemid = pmtxt
			this.lingquBtn()
		},
		lingquBtn(){
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_y_jianhuo',
				'i':this.FNULLE([
				'opmode','Y_GFJS_qryjhrq',
				'czyid',this.ryuser.operatorid,
				'kqid', this.ryuser.kqid,
				'jhrq',this.editForm.jhrq,
				'itemid',this.editForm.itemid,
				])
				},'领取改货拣数',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到领取改货拣数")
					console.log(rtn_json_obj)
					_self.skuData = rtn_json_obj
					if(_self.skuData.length > 0){
						_self.isSkuVisible = true
					}else{
						_self.$toast.fail('暂无商品详情')
					}
				}
			});
		},
		selectSkuClick(row,i){
			this.editForm.jhrq = row.jhrq
			this.editForm.itemid = row.itemid
			this.editForm.bill = row.bill
			this.editForm.ck_storeid = row.ck_storeid
			this.editForm.cwno = row.cwno
			// this.editForm.itemid = row.itemid
			this.editForm.jhbq = row.jhbq
			this.editForm.jhr = row.jhr
			this.editForm.pack = row.pack
			this.editForm.qty = row.qty
			this.editForm.subid = row.subid
			this.editForm.subsname = row.subsname
			this.editForm.unit = row.unit
			this.editForm.yjtotqty = row.yjtotqty
      this.editForm.xs_ck_storeid = row.xs_ck_storeid
			this.isSkuVisible = false
		},
		saveGoodsBtn(){
			console.log(this.editForm)
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_y_jianhuo',
					'i':this.FNULLE([
					'opmode','Y_GFJS_xgitemid',
					'kqid', this.ryuser.kqid,
					'czyid',this.ryuser.operatorid,
					'jhrq',this.editForm.jhrq,
					'itemid',this.editForm.itemid,
					'subid',this.editForm.subid,
					'cwno',this.editForm.cwno,
					'bill',this.editForm.bill,
					'unit',this.editForm.unit,
					'pack',this.editForm.pack,
					'qty',this.editForm.qty,
					'yjtotqty',this.editForm.yjtotqty,
					'ck_storeid',this.editForm.ck_storeid,
				])
				}, '拣货修改提交',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到拣货修改提交")
					console.log(rtn_json_obj[0])
					if(rtn_json_obj[0].ret_ret == '-1'){
						_self.$dialog.alert({
						  title: '提示',
						  message:rtn_json_obj[0].ret_mess,
							onfirmButtonColor:'#1989fa'
						}).then(() => {
						  // on close
						});
					}else{
						_self.$toast(rtn_json_obj[0].ret_mess)
						_self.editForm.jhrq = ''
						_self.editForm.itemid = ''
						_self.editForm.bill = ''
						_self.editForm.ck_storeid = ''
						_self.editForm.cwno = ''
						_self.editForm.jhbq = ''
						_self.editForm.jhr = ''
						_self.editForm.pack = ''
						_self.editForm.qty = ''
						_self.editForm.subid = ''
						_self.editForm.subsname = ''
						_self.editForm.unit = ''
						_self.editForm.yjtotqty = ''
						_self.editForm.xs_ck_storeid = ''
					}
				}
			});
		},
  },
  mounted() {

  },
	components: {

	},
};
</script>

<style lang="scss" scoped>
	// 引入公共样式
	@import '@/assets/css/base.scss';
	@import '@/assets/css/input.scss';
	div.zhengtuojianhuo{
		padding-top: 50px;
	}
</style>
